﻿@using RooHui.Infrastructure.Entities.Enum;
@{
    ViewBag.Title = "Project";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section head{
    <link rel="Stylesheet" type="text/css" href="/content/css/pages/blog.css" />
    <link rel="Stylesheet" type="text/css" href="/content/css/pages/page_search.css" />
    <link rel="Stylesheet" type="text/css" href="/content/css/pages/page_magazine.css" />
}
<div class="breadcrumbs margin-bottom-40">
    <div class="container">
        <h3 class="pull-left blue">
            项目列表</h3>
    </div>
</div>
<div class="container">
    <div class="row-fluid blog-page">
        <div class="span9 md-margin-bottom-40">
            @{
                RooHui.Infrastructure.Entities.ItemListBox<RooHui.Portal.Biz.Model.ProjectItemModel> data = ViewBag.Projects;
                if (data != null && data.Data != null && data.Data.Any())
                {
                    foreach (var item in data.Data)
                    {
                <div class="search-blocks search-blocks-top-blue">
                    <div class="row-fluid">
                        <div class="span7">
                            <h2>
                                <a target="_blank" href="/project/detail?id=@item.ProjectId" class="blue">@item.ProductName @item.ProjectTitle
                                </a><span style="color: #777; font-size: 12px;">项目编码：@item.ProjectCode</span>
                            </h2>
                            <div class="span12" style="height: 50px; line-height: 50px; margin-left: 0px;">
                                @{
                        switch (item.ProjectStatus)
                        {
                            default:
                            case ProjectStatus.Publish:
                                    if(item.ReleaseTime > DateTime.Now)
                                    {
                                    <span style="margin-right: 10px;" class="label label-warning">
                                        @item.ReleaseTime.ToString("MM.dd HH:mm") 发布
                                    </span>
                                    }
                                    else
                                    {
                                    <span style="margin-right: 10px;" class="label label-success">
                                        @item.ProjectStatus.Mapping()
                                    </span>
                                    }
                                    
                                    break;
                            case ProjectStatus.Full:
                            case ProjectStatus.Success:
                            case ProjectStatus.Repayment:
                            case ProjectStatus.Complete:
                                    <span style="margin-right: 10px;" class="label label-info">@item.ProjectStatus.Mapping()
                                    </span>
                                                                                          break;
                        }
                                }
                                <span style="margin-right: 10px;" class="poptag"  data-toggle="popover" data-placement="right"  data-trigger="hover" data-html="true" data-original-title=""
                                data-content="@item.ProjectPolicyModel.FirstOrDefault(c => !c.IsAttach).BalanceType.Description()"><i class="icon-bar-chart" style="margin-right: 5px;">
                                </i>@item.ProjectPolicyModel.FirstOrDefault(c => !c.IsAttach).BalanceType.Mapping()</span> <span style="margin-right: 10px;" class="poptag" data-toggle="popover" data-placement="right"  data-trigger="hover" data-html="true" data-original-title=""
                                data-content="@(RooHui.Infrastructure.Configuration.SiteSettings.SiteName)承诺当项目出现风险时，先行赔付项目本金+全部利息">
                                    <i class="icon-lock" style="margin-right: 5px;"></i>先行赔付保证</span> <span data-toggle="popover" class="poptag" data-placement="right"  data-trigger="hover" data-html="true" data-original-title=""
                                data-content="由@(item.CompanyName)全额本息承保">
                                        <img style="width:20px; height:20px;" alt="@item.CompanyName" src="@item.LogoImage" />@item.CompanyName</span>
                            </div>
                            <div class="span12" style="height: 60px; line-height: 60px; margin-left: 0px;">
                                <div class="span4">
                                    @if (item.ProjectStatus == ProjectStatus.Publish)
                                    {
                                        if (item.ReleaseTime > DateTime.Now)
                                        {
                                            <a target="_blank" class="btn btn-info btn-large disabled"  href="javascript:;"><i
                                                class="icon-time"></i> 立刻投标 </a>
                                        }
                                        else
                                        {
                                            <a target="_blank" class="btn btn-info btn-large" href="/project/detail?id=@item.ProjectId"><i
                                                class="icon-legal"></i> 立刻投标 </a>
                                        }
                                    }
                                    else
                                    {
                                        <button disabled="disabled" class="btn btn-inverse btn-large disabled">
                                            <i class="icon-legal"></i> 立刻投标
                                        </button>
                                    }
                                </div>
                                <div class="span8 realdata" real-id="@item.ProjectId" id="realdata_@item.ProjectId">
                                </div>
                            </div>
                        </div>
                        <div class="span5">
                            <div class="row-fluid">
                                <div class="span12" style="line-height: 36px; border-bottom: 1px dashed #ccc;">
                                    <div class="span6">
                                        融资金额：</div>
                                    <div class="span6">
                                        @(Math.Round(item.Financing / 10000, 2))万元</div>
                                </div>
                                <div class="span12" style="line-height: 36px; margin: 0; border-bottom: 1px dashed #ccc;">
                                    <div class="span6">
                                        年化收益率：</div>
                                    <div class="span6" style="color: #e86e00; font-size: 16px;">
                                        <span class="poptag" style="border-bottom: 1px dashed #333; font-weight: bold;" data-toggle="popover" data-html="true" data-placement="right"  data-trigger="hover" data-html="true" data-original-title=""
                                            data-content="@item.PolicyDescription">
                                        @(Math.Round(item.ProjectPolicyModel.FirstOrDefault(c => !c.IsAttach).Rate, 2).ToString()) %
                                        @if (item.ProjectPolicyModel.Any(c => c.IsAttach))
                                        {
                                            @:+ 奖励
                                        }
                                        </span>
                                        </div>
                                </div>
                                <div class="span12" style="line-height: 36px; margin: 0; border-bottom: 1px dashed #ccc;">
                                    <div class="span6">
                                        融资期限：</div>
                                    <div class="span6">
                                        @(item.CycleAmount) 期&nbsp;&nbsp;&nbsp;(@item.ProjectPolicyModel.FirstOrDefault(c => !c.IsAttach).Duration @(item.ProjectPolicyModel.FirstOrDefault(c => !c.IsAttach).DurationType.Mapping())/期)</div>
                                </div>
                                <div class="span12" style="line-height: 36px; margin: 0; border-bottom: 1px dashed #ccc;">
                                    <div class="span6">
                                        @((int)item.ProjectStatus < (int)ProjectStatus.Repayment ? "预计" : "")起息日：</div>
                                    <div class="span6">
                                    @item.BeginDate.ToString("yyyy.MM.dd")
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="margin-bottom-20 clearfix">
                </div>
                    }
                }
            }
            @Html.Raw(data.PageItemSegment)
        </div>
        <div class="span3" style="background-color: #fafafa; border: 1px solid #ccc; padding: 5px;">
            <div class="posts margin-bottom-40">
                <div class="headline headline-md">
                    <h2>
                        投资咨询</h2>
                </div>
                <dl class="dl-horizontal">
                    <dt><a href="#">
                        <img src="assets/img/sliders/elastislide/6.jpg" alt=""></a></dt>
                    <dd>
                        <p>
                            <a href="#">Responsive Bootstrap 3 Template placerat idelo alac eratamet.</a></p>
                    </dd>
                </dl>
                <dl class="dl-horizontal">
                    <dt><a href="#">
                        <img src="assets/img/sliders/elastislide/10.jpg" alt=""></a></dt>
                    <dd>
                        <p>
                            <a href="#">100+ Amazing Features Layer Slider, Layer Slider, Icons, 60+ Pages etc.</a></p>
                    </dd>
                </dl>
                <dl class="dl-horizontal">
                    <dt><a href="#">
                        <img src="assets/img/sliders/elastislide/11.jpg" alt=""></a></dt>
                    <dd>
                        <p>
                            <a href="#">Developer Friendly Code imperdiet condime ntumi mperdiet condim.</a></p>
                    </dd>
                </dl>
            </div>
            <div class="headline headline-md">
                <h2>
                    常见问题</h2>
            </div>
            <ul>
                <li><a href="javascript:;">什么是预期年化收益率</a></li>
                <li><a href="javascript:;">我的投资是否有保障</a></li>
                <li><a href="javascript:;">怎么进行投资</a></li>
                <li><a href="javascript:;">如何申请成为代理人</a></li>
                <li><a href="javascript:;">是否能赚取更多的利率</a></li>
            </ul>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript">
        $(function () {
            $('#labproject').addClass('active');
            $('.poptag').each(function () {
                $(this).popover();
            });
            loadProjectSchedule();
        });
        function loadProjectSchedule() {
            var pids = [];
            $('.realdata').each(function () {
                pids.push($(this).attr('real-id'));
            });
            $.ajax({
                url: '/project/projectschedule',
                cache: false,
                type: 'get',
                data: {
                    pids: pids.join(',')
                },
                error: function () {
                    $.get('/home/log', { msg: 'Load /project/projectschedule fail! ids:' + pids.join(',') });
                },
                success: function (result) {
                    var data = eval('(' + result + ')');
                    $.each(data, function () {
                        $('#realdata_' + this.ProjectId).html(
                            '<div class="progress ' + this.ProgressStyle + ' progress-striped" style="margin: 10px 0;">' +
                                '<div class="bar" style="width:' + this.Schedule + '"></div>' +
                                '</div>' +
                                '<p>总融资额 <span style="color: #3498db;">￥ ' + this.Total + ' 万元</span>，剩余 <span style="color: #e86e00;">￥ ' + this.Real + ' 万元</span>' +
                                '</p>');
                    });
                }
            });
        }
    </script>
}
